<!doctype html>
{% load static %}
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>我的收藏</title>
    <link href="{% static 'css/css.css' %}" rel="stylesheet" type="text/css">
    <script src="{% static 'admin/js/jquery.min.js' %}"></script>
</head>
<body>
<div class="zuji_title">
    <span>我的收藏</span>
</div>
<div class="zu_list">
    <ul>
    </ul>
</div>
</body>
<script>
    loadFootprint()

    function loadFootprint(){
        $.get(
            "/personal/getCollection",
            function (res){
                if(res.code==200){
                    let goodsList = res.data;
                    for(let i=goodsList.length-1;i>=0;i--){
                        let goods = goodsList[i];
                        let li = document.createElement("li");
                        li.addEventListener('click',function (){
                            toGoods(goods.id)
                        })
                        let img = document.createElement("img");
                        img.title = goods.goods_title;
                        img.src = goods.goods_img;
                        li.append(img);
                        let div = document.createElement("div");
                        div.className = "font";
                        let h2 = document.createElement("h2");
                        h2.innerHTML = "￥ "+goods.goods_price;
                        div.append(h2);
                        let p = document.createElement("p");
                        p.innerHTML = goods.goods_title;
                        p.title = goods.goods_title;
                        div.append(p)
                        li.append(div)
                        $(".zu_list > ul").append(li)
                    }
                }
            }
        )
    }

    //进入详情
    function toGoods(id) {
        window.parent.location.href = "/details.html?goods_id=" + id
    }
</script>
